package com.gridpower.spreadsheet.server;

import java.util.ArrayList;

import com.gridpower.spreadsheet.client.FileService;
import com.gridpower.spreadsheet.client.models.GridCell;
import com.gridpower.spreadsheet.client.models.AppModel.RemoteFileInfo;
import com.gridpower.spreadsheet.client.models.AppModel.DocInfo;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class FileServiceImpl extends RemoteServiceServlet implements FileService {

	public RemoteFileInfo getFileInfo(int id, String fileName) {
		// TODO Auto-generated method stub
		RemoteFileInfo test = new RemoteFileInfo();
		test.currentDocId = 0;
		test.docIds = new ArrayList();
		test.docIds.add(0);
		test.docIds.add(1);
		test.docNames.add("doc1");
		test.docNames.add("doc2");
		DocInfo di = new DocInfo();
		di.colCount = 'T'-'A'+1;
		di.rowCount = 100;
		DocInfo di1 = new DocInfo();
		di1.colCount = 'T'-'A'+1;
		di1.rowCount = 20;
		di.fixedColCount = 1;
		di.fixedRowCount = 1;
		test.docInfos.add(di);
		test.docInfos.add(di1);
		test.docNum = 2;
		test.fileId = id;
		
		return test;
	}

	public GridCell[] getAllCellsForDoc(int docId) {
		// TODO Auto-generated method stub
		int mxSz = 16;
		GridCell[] cells = new GridCell[mxSz];
		for (int i = 0; i < mxSz; ++i) {
			cells[i] = new GridCell(); 
			cells[i].setCol(i);
			cells[i].setRow(i);
			cells[i].setDisplayString(Integer.toString(i));
			cells[i].setHeight(30);
			cells[i].setWidth(45);
		}
		return cells;
	}
}
